home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.5 KB | 63 lines | [TEXT/GEOL] |
- Item 5035151 19-Dec-89 17:55
-
- From: ALCABES Alcabes, Harvey
-
- To: CP.ARCHIVES C++ Archives
-
- Sub: learning c++
-
- Item 8456638 17-Nov-89 05:34
-
- From: D2078 AS & M, Alan Dail,PRT
-
- To: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.ADMIN C++ Group Addresses Administrator
-
- Sub: learning c++
-
- I'm trying to learn c++ and have a question?
-
- i am currently doing something like the following:
-
- HandleObject*& newRef (HandleObject*& h) {
- cout << "reassign reference " << h << '\n';
- return h;
- }
-
- HandleObject*& addRef (HandleObject*& h) {
- cout << "new reference " << h << '\n';
- return h;
- }
-
- void delRef (HandleObject*& h) {
- cout << "delete reference " << h << '\n';
- return h;
- }
-
- main () {
- HandleObject* h = addRef (new HandleObject);
- newRef (h) = addRef (h);
- delRef (h);
- }
-
- to trace assignements, but would much rather not have to explicitly call
- addRef, newRef & delRef. is there a way to set it up so that using =
- automaticaly will do something like
- operator = (HandleObject* & a, HandleObject* & b) {
- ::operator = (newRef (a), delRef (b));
- };
-
- and to have delRef automatically called at the end of a function. I need this
- to be done for all HandleObject* (and descendants).
-
- any help would be greatly appreciated.
-
- also, i tried to sent this to cplus.apple$, but got an error (address not
- found).
-
- thanks
-
- alan dail
-
-
-